<?php
// cookie
setcookie("user", "Alex Porter", time() + 30);

// SESSION
session_start();

if (isset($_SESSION['views']))
    $_SESSION['views'] = $_SESSION['views'] + 1;
else
    $_SESSION['views'] = 1;
echo "SESSION[Views]: " . $_SESSION['views'];

// unset() 函数用于释放指定的 session 变量：
// unset($_SESSION['views']);

// session_destroy() 将重置 session，您将失去所有已存储的 session 数据。
// session_destroy();

?>


<html>
<head lang="en">
    <meta charset="UTF-8">
</head>
<body>

<br>
<?php
if (isset($_COOKIE["user"]))
    echo "Welcome " . $_COOKIE["user"] . "!<br />";
else
    echo "Welcome guest!<br />";

// set the expiration date to one hour ago
// setcookie("user", "", time()-3600);


?>


</body>
</html>